package com.jqb.ajax.servlet;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletException;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * Created by IntelliJ IDEA.
 * User: jqbxd
 * Date: 2009-3-31
 * Time: 16:07:25
 * To change this template use File | Settings | File Templates.
 */
public class CheckServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	@Override
    protected void doGet(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws ServletException, IOException {
       doPost(httpServletRequest, httpServletResponse);
    }

    @Override
    protected void doPost(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws ServletException, IOException {
        httpServletResponse.setContentType("text/html; charset=utf-8");
        PrintWriter out=httpServletResponse.getWriter();
        String name=httpServletRequest.getParameter("name");
        if(name==null || name.equals("")){
            out.println("用户名不能为空!  请重新输入!");
        }else if(name.equals("jqb")){
            out.println("欢迎["+name+"]登录!");
        }else{
            out.println("用户["+name+"]不存在!");
        }
        out.println("<br/><a href=\"index.html\">返回</a>");
    }
}
